package com.example.pattern.singleton;

public class EnumSingletonTest {

    public static void main(String[] args) {
        EnumSingleton instance = EnumSingleton.INSTANCE;
        EnumSingleton instance1 = EnumSingleton.INSTANCE;
        instance.test();
        instance1.test();
        System.out.println(instance == instance1);
    }

}

enum EnumSingleton{

    INSTANCE;

    public void test(){
        System.out.println("执行test方法。。。");
    }

    public void print(){
        System.out.println(this.hashCode());
    }
}